package com.atguigu.day08;

import com.atguigu.utils.ClickEvent;
import com.atguigu.utils.ClickSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.runtime.operators.GenericWriteAheadSink;

public class Example4 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env =
                StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        env
                .fromElements(1,2,3,4,5)
                .keyBy(r -> r % 2)
                .sum(0)
                .print();

//        env
//                .addSource(new ClickSource())
//                .addSink(new GenericWriteAheadSink<ClickEvent>() {
//                    @Override
//                    protected boolean sendValues(Iterable<ClickEvent> values, long checkpointId, long timestamp) throws Exception {
//                        for (ClickEvent e : values) System.out.println(e);
//                    }
//                })

        env.execute();
    }
}
